package semSimilarity.sentence;

import java.util.List;

import semSimilarity.P;
import semSimilarity.SimilarityGenerator;
import semSimilarity.SimilarityMatrix;
import sentStruct.Noun;

public class NounSimGenerator implements SimilarityGenerator<Noun>{
	
	

	@Override
	public double similarity(Noun el1, Noun el2) {
		double similarity = 0;
		double baseCoeff = 0;
		PartOfSpeechSimGenerator simGen = new PartOfSpeechSimGenerator();
		
		if (el1==null||el2==null)
			return 0;
		
		if (el1.getPreposition()!=null || el2.getPreposition()!=null){
			similarity+=P.nounSim.preposCoeff*simGen.similarity(el1.getPreposition(), el2.getPreposition());
			baseCoeff+=P.nounSim.preposCoeff;
		}
		if (el1.hasAdjectives()||el2.hasAdjectives()){
			similarity+= P.nounSim.adjCoeff*simGen.similarity(el1.getAdjectives(), el2.getAdjectives());
			baseCoeff+= P.nounSim.adjCoeff;
			}
		similarity += P.nounSim.nounCoeff*simGen.similarity(el1, el2);
		baseCoeff += P.nounSim.nounCoeff;
		
		return similarity/baseCoeff;
	}



	@Override
	public double similarity(List<? extends Noun> list1,
			List<? extends Noun> list2) {
		if (list1==null||list2==null)
			return 0;
		SimilarityMatrix<Noun> matrix = new SimilarityMatrix<Noun>(list1, list2, this);
		return matrix.maxSimilarityAverage();
	}

}
